package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionsDemo {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<Integer>();
        list.addAll(Arrays.asList(new Integer[] { 1, 9, 4, 7, 3, 2 }));
        System.out.println("Original list: " + list);
        Collections.shuffle(list);
        System.out.println("Shuffled list: " + list);
        Collections.reverse(list);
        System.out.println("Reversed list: " + list);
        Collections.swap(list, 0, list.size() - 1);
        System.out.println("Swapped list: " + list);
        Collections.sort(list);
        System.out.println("Sorted list: " + list);
        System.out.println("7 in " + list + " is at index " + Collections.binarySearch(list, 7));
    }
}
